package io.renren.sf.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.sf.dao.HzCopyingSteleCalligraphyCharacterDao;
import io.renren.sf.entity.HzCopyingSteleCalligraphyCharacterEntity;
import io.renren.sf.service.HzCopyingSteleCalligraphyCharacterService;


@Service("hzCopyingSteleCalligraphyCharacterService")
public class HzCopyingSteleCalligraphyCharacterServiceImpl extends ServiceImpl<HzCopyingSteleCalligraphyCharacterDao, HzCopyingSteleCalligraphyCharacterEntity> implements HzCopyingSteleCalligraphyCharacterService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<HzCopyingSteleCalligraphyCharacterEntity> page = this.page(
                new Query<HzCopyingSteleCalligraphyCharacterEntity>().getPage(params),
                new QueryWrapper<HzCopyingSteleCalligraphyCharacterEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 根据sid删除碑帖字记录
     * @param sid
     * @return
     */
    @Override
    public int removeCaracterBySid(Long sid) {
        return this.baseMapper.delete(new QueryWrapper<HzCopyingSteleCalligraphyCharacterEntity>().eq("sid",sid));
    }

    @Override
    public List<HzCopyingSteleCalligraphyCharacterEntity> getBySid(long sid) {
        return this.baseMapper.selectList(new QueryWrapper<HzCopyingSteleCalligraphyCharacterEntity>().eq("sid",sid).orderByAsc("corder"));
    }

}